from enum import Enum


class ErrorCode(Enum):
    """
    自定义错误码
    """

    SUCCESS = (0, "ok")
    PARAMS_ERROR = (40000, "请求参数错误")
    NOT_LOGIN_ERROR = (40100, "未登录")
    NO_AUTH_ERROR = (40101, "无权限")
    NOT_FOUND_ERROR = (40400, "请求数据不存在")
    FORBIDDEN_ERROR = (40300, "禁止访问")
    SYSTEM_ERROR = (50000, "系统内部异常")
    OPERATION_ERROR = (50001, "操作失败")

    def __init__(self, code, message):
        """
        初始化错误码枚举

        :param code: 状态码
        :param message: 信息
        """
        self.code = code
        self.message = message

    def __str__(self):
        return f"ErrorCode(code={self.code}, message='{self.message}')"